package cn.com.lyj6851.modules.cart.service.mapper;

import cn.com.lyj6851.common.mapper.CoreMapper;
import cn.com.lyj6851.modules.cart.domain.YdyStoreCart;
import cn.com.lyj6851.modules.order.service.dto.CountDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StoreCartMapper extends CoreMapper<YdyStoreCart> {

    @Select("select IFNULL(sum(cart_num),0) from ydy_store_cart " +
            "where is_pay=0 and is_del=0 and is_new=0 and uid=#{uid}")
    int cartSum(@Param("uid") Long uid);


    @Select("SELECT t.cate_name as catename from ydy_store_cart c  " +
            "LEFT JOIN ydy_store_product p on c.product_id = p.id  " +
            "LEFT JOIN ydy_store_category t on p.cate_id = t.id " +
            "WHERE c.is_pay = 1")
    List<CountDto> findCateName();
}